﻿using Microsoft.AspNetCore.Mvc;
using MVC_System.DTO.ProductionOrdersDTO;
using MVC_System.DTO.productionPickingDTO;
using WMS_MAV;

namespace MVC_System.Controllers
{
    public class productionPickingController : Controller
    {
        private readonly IConfiguration _configuration;
        public productionPickingController(IConfiguration configuration)
        {
            _configuration = configuration;
        }
        /// <summary>
        /// 生产领料显示视图
        /// </summary>
        /// <returns></returns>
        public IActionResult productionPickingShow()
        {
            return View();
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task<ActionResult> ProductionOrdersShow(productionPickingShowDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "HysSwagger/api/ProductionRequisition/GetProductionRequisition?requisitionNumber=" + dto.requisitionNumber + "&state=" + dto.state + "&requisitionDate=" + dto.requisitionDate;
            var respomse = await client.GetAsync(url);
            return Json(respomse);
        }
        /// <summary>
        /// 生产领料添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult productionPickingAdd()
        {
            return View();
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task<ActionResult> ProductionOrdersAdd(productionPickingAddDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "HysSwagger/api/ProductionRequisition/AddProductionRequisition";
            var respomse = await client.PostAsync(url, dto.Data);
            return Json(respomse);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task<ActionResult> productionPickingDelete(productionPickingDeleteDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "HysSwagger/api/ProductionRequisition/DeleteProductionRequisition";
            var respomse = await client.PostAsync(url, dto.Data);
            return Json(respomse);
        }
        public IActionResult productionPickingModelView()
        {
            return View();
        }
        public async Task<ActionResult> productionPickingModel(productionPickingModelDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "HysSwagger/api/ProductionRequisition/GetProductionRequisitionModel?productionRequisitionId=" + dto.productionRequisitionId;
            var respomse = await client.GetAsync(url);
            return Json(respomse);
        }
    }
}
